/** 人员识别记录 */
<template>
  <div class="container">
    <div class="btns">
      <el-form :inline="true" :model="formData" class="demo-form-inline">
        <el-input v-model="formData.input" style="width: 240px" placeholder="请输入识别结果" clearable />
        <!-- <el-select v-model="formData.carstatus" clearable placeholder="请选择无人车状态">
          <el-option v-for="item in carStatusList" :key="item.id" :label="item.status" :value="item.value">
          </el-option>
        </el-select> -->
        <el-form-item>
          <el-button type="primary" @click="getData">查询</el-button>
        </el-form-item>
      </el-form>
    </div>

    <!-- 表格区域 -->
    <el-table :data="dataList" style="width: 100%">
      <el-table-column type="index" :index="indexMethod()" width="50">
      </el-table-column>
      <el-table-column label="识别图片">
        <template slot-scope="scope">
          <img :src="scope.row.image_path" alt="">
        </template>
      </el-table-column>
      <el-table-column prop="result" label="识别结果">
      </el-table-column>
      <el-table-column prop="recognition_time" label="查询时间">
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
      :current-page="paginationData.page" :page-sizes="[10, 20, 30, 40]" :page-size="paginationData.page_size"
      layout="total, sizes, prev, pager, next, jumper" :total="paginationData.total">
    </el-pagination>
  </div>
</template>
<script>
import { get, post, Delete, put } from '@/utils/request.js'
export default {
  data() {
    return {
      formData:{
        input:''
      },
      dataList:[],
      paginationData:{
        page: 1,
        page_size: 10,
        total: 0
      }
    }
  },
  methods:{
    //计算序号
    indexMethod(){
      let temp = this.paginationData.page_size * (this.paginationData.page - 1)
      return temp + 1
    },
    // 获取历史数据
    getData(){
      get(`/face/face_records/?fuzzy_result=${this.formData.input}`,this.paginationData).then(res=>{
        this.dataList = res.data
        this.paginationData.total = res.pagination.total
      }).catch(err=>{
        console.log(err)
      })
    },
    showDialog(){},

    // 分页事件
    // 分页事件
    handleSizeChange(val) {
      this.paginationData.page_size = val
      this.getData()
    },
    handleCurrentChange(val) {
      this.paginationData.page = val
      this.getData()
    }
  },
  
  created(){
    this.getData()
  }
}
</script>
<style scoped></style>